package agend.behaviours.registration;

import jade.core.behaviours.OneShotBehaviour;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import agend.db.DBInsert;

/**
 * Bheaviour che scrive sul DB l'username e la
 * password settati
 */
public class DbUserRegistrationBehaviour extends OneShotBehaviour{

	private static final long serialVersionUID = 1L;

	private String username;
	private String password;

	@Override
	public void action() {

		try {

			PreparedStatement preparedStatement = DBInsert.getPreparedStatement();

			preparedStatement.setString(1, username);
			preparedStatement.setString(2, password);

			preparedStatement.executeUpdate();

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public void setPassword(String password) {
		this.password = password;
	}
}

